File tree Expand file tree Collapse file tree 4 files changed +90
-1
lines changed
src/dotty/tools/dotc/transform Expand file tree Collapse file tree 4 files changed +90
-1
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ class Splitter extends TreeTransform {
70
70
}
71
71
72
72
def isStructuralSelect (tp : Type ): Boolean = tp.stripTypeVar match {
73
- case tp : RefinedType => tp.refinedName == name || isStructuralSelect(tp)
73
+ case tp : RefinedType => tp.refinedName == name || isStructuralSelect(tp.parent )
74
74
case tp : TypeProxy => isStructuralSelect(tp.underlying)
75
75
case AndType (tp1, tp2) => isStructuralSelect(tp1) || isStructuralSelect(tp2)
76
76
case _ => false
Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ class tests extends CompilerTest {
75
75
defaultOptions = noCheckOptions)
76
76
// -Ycheck fails because there are structural types involving higher-kinded types.
77
77
// these are illegal, but are tested only later.
78
+ @ Test def neg_zoo = compileFile(negDir, " zoo" , xerrors = 1 )
78
79
@ Test def neg_t1192_legalPrefix = compileFile(negDir, " t1192" , xerrors = 1 )
79
80
@ Test def neg_tailcall_t1672b = compileFile(negDir, " tailcall/t1672b" , xerrors = 6 )
80
81
@ Test def neg_tailcall_t3275 = compileFile(negDir, " tailcall/t3275" , xerrors = 1 )
Original file line number Diff line number Diff line change
1
+ object Test {
2
+ type Meat = {
3
+ type IsMeat = Any
4
+ }
5
+ type Grass = {
6
+ type IsGrass = Any
7
+ }
8
+ type Animal = {
9
+ type Food
10
+ def eats (food : Food ): Unit
11
+ def gets : Food
12
+ }
13
+ type Cow = {
14
+ type IsMeat = Any
15
+ type Food <: Grass
16
+ def eats (food : Grass ): Unit
17
+ def gets : Grass
18
+ }
19
+ type Lion = {
20
+ type Food = Meat
21
+ def eats (food : Meat ): Unit
22
+ def gets : Meat
23
+ }
24
+ def newMeat : Meat = new {
25
+ type IsMeat = Any
26
+ }
27
+ def newGrass : Grass = new {
28
+ type IsGrass = Any
29
+ }
30
+ def newCow : Cow = new {
31
+ type IsMeat = Any
32
+ type Food = Grass
33
+ def eats (food : Grass ) = ()
34
+ def gets = newGrass
35
+ }
36
+ def newLion : Lion = new {
37
+ type Food = Meat
38
+ def eats (food : Meat ) = ()
39
+ def gets = newMeat
40
+ }
41
+ val milka = newCow
42
+ val leo = newLion
43
+ leo.eats(milka) // structural select not supported
44
+ }
Original file line number Diff line number Diff line change
1
+ object Test {
2
+ type Meat = {
3
+ type IsMeat = Any
4
+ }
5
+ type Grass = {
6
+ type IsGrass = Any
7
+ }
8
+ type Animal = {
9
+ type Food
10
+ def eats (food : Food ): Unit
11
+ def gets : Food
12
+ }
13
+ type Cow = {
14
+ type IsMeat = Any
15
+ type Food <: Grass
16
+ def eats (food : Grass ): Unit
17
+ def gets : Grass
18
+ }
19
+ type Lion = {
20
+ type Food = Meat
21
+ def eats (food : Meat ): Unit
22
+ def gets : Meat
23
+ }
24
+ def newMeat : Meat = new {
25
+ type IsMeat = Any
26
+ }
27
+ def newGrass : Grass = new {
28
+ type IsGrass = Any
29
+ }
30
+ def newCow : Cow = new {
31
+ type IsMeat = Any
32
+ type Food = Grass
33
+ def eats (food : Grass ) = ()
34
+ def gets = newGrass
35
+ }
36
+ def newLion : Lion = new {
37
+ type Food = Meat
38
+ def eats (food : Meat ) = ()
39
+ def gets = newMeat
40
+ }
41
+ val milka = newCow
42
+ val leo = newLion
43
+ // leo.eats(milka) // structural select not supported
44
+ }
You can’t perform that action at this time.
0 commit comments