bcc
bcc copied to clipboard
[Generics] Nested generics & import issue
Good day,
Thanks for all the updates lately! Greatly appreciated.
Here's another bug I've found:
Test.bmx
Framework BRL.Blitz
Import BRL.Collections
Import BRL.StandardIO
'Import "Bar.bmx"
Include "Bar.bmx"
Include "TreeMap2D.bmx"
New TBar()
Bar.bmx
'Framework BRL.Blitz
'Import "TreeMap2D.bmx"
Type TBar
Global map:TTreeMap2D<UInt, String, TBar> = New TTreeMap2D<UInt, String, TBar>()
Method New()
map[1, "test"] = Self
EndMethod
EndType
TreeMap2D.bmx
'Framework BRL.Blitz
'Import BRL.Collections
Type TTreeMap2D<A, B, C>
Private
Field map:TTreeMap<A, TTreeMap<B, C>> = New TTreeMap<A, TTreeMap<B, C>>()
Public
Method Operator[]:TTreeMap<B, C>(ka:A)
Return map[ka]
EndMethod
Method Operator[]:C(ka:A, kb:B)
If Not map[ka]
Return Null
EndIf
Return map[ka][kb]
EndMethod
Method Operator[]=(ka:A, kb:B, val:C)
If Not map[ka]
map[ka] = New TTreeMap<B, C>()
EndIf
map[ka][kb] = val
EndMethod
Method Clear()
map.Clear()
EndMethod
Method Contains:Int(ka:A)
Return map[ka] <> Null
EndMethod
Method Contains:Int(ka:A, kb:B)
If Not map[ka]
Return False
EndIf
Return map[ka][kb] <> Null
EndMethod
Method Keys:ICollection<A>()
Return map.Keys()
EndMethod
Method Keys:ICollection<B>(ka:A)
If Not map[ka]
Return New TArrayList<B>(0)
EndIf
Return map[ka].Keys()
EndMethod
Method SubKeys:ICollection<B>()
Local list:TLinkedList<B> = New TLinkedList<B>()
For Local map:TTreeMap<B, C> = EachIn Self.map.Values()
For Local key:B = EachIn map.Keys()
list.AddLast(key)
Next
Next
Return list
EndMethod
Method Values:ICollection<C>(ka:A)
If Not map[ka]
Return New TArrayList<C>(0)
EndIf
Return map[ka].Values()
EndMethod
Method Values:ICollection<C>()
Local list:TLinkedList<C> = New TLinkedList<C>()
For Local ka:A = EachIn map.Keys()
For Local v:C = EachIn map[ka].Values()
list.AddLast(v)
Next
Next
Return list
EndMethod
Method Count:Int()
Return map.Count()
EndMethod
Method Count:Int(ka:A)
If Not map[ka]
Return 0
EndIf
Return map[ka].Count()
EndMethod
Method TotalCount:Int()
Local count:Int
For Local map:TTreeMap<B, C> = EachIn map.Values()
count:+map.Count()
Next
Return count
EndMethod
Method Remove:Int(ka:A)
Return map.Remove(ka)
EndMethod
Method Remove:Int(ka:A, kb:B)
If Not map[ka]
Return False
EndIf
Return map[ka].Remove(kb)
EndMethod
Method IsEmpty:Int()
Return map.IsEmpty()
EndMethod
Method IsEmpty:Int(ka:A)
If Not map[ka]
Return True
EndIf
Return map[ka].IsEmpty()
EndMethod
EndType
When using include it works fine, but when importing it does not.
Thanks!