Skip to content

Commit 1ae6db3

Browse files
authored
Merge pull request #10226 from dotty-staging/cook-classTparams
Handle raw types in bounds of Java class type params
2 parents eddd4da + 7675ad2 commit 1ae6db3

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,11 +461,17 @@ class ClassfileParser(
461461
val ts = new ListBuffer[Type]
462462
while (sig(index) == ':') {
463463
index += 1
464-
if (sig(index) != ':') // guard against empty class bound
465-
ts += sig2type(tparams, skiptvs)
464+
if (sig(index) != ':') { // guard against empty class bound
465+
val tp = sig2type(tparams, skiptvs)
466+
if (!skiptvs)
467+
ts += cook(tp)
468+
}
469+
}
470+
if (!skiptvs) {
471+
val bound = if ts.isEmpty then defn.AnyType else ts.reduceLeft(AndType.apply)
472+
TypeBounds.upper(bound)
466473
}
467-
val bound = if ts.isEmpty then defn.AnyType else ts.reduceLeft(AndType.apply)
468-
TypeBounds.upper(bound)
474+
else NoType
469475
}
470476

471477
var tparams = classTParams
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
class A_1<T> {}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class B_1<S extends A_1> {
2+
public B_1(S s) { }
3+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
object Test {
2+
val a = new A_1[String]
3+
val b = new B_1(a)
4+
}

0 commit comments

Comments
 (0)