Skip to content

Handle raw types in bounds of Java class type params #10226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,17 @@ class ClassfileParser(
val ts = new ListBuffer[Type]
while (sig(index) == ':') {
index += 1
if (sig(index) != ':') // guard against empty class bound
ts += sig2type(tparams, skiptvs)
if (sig(index) != ':') { // guard against empty class bound
val tp = sig2type(tparams, skiptvs)
if (!skiptvs)
ts += cook(tp)
}
}
if (!skiptvs) {
val bound = if ts.isEmpty then defn.AnyType else ts.reduceLeft(AndType.apply)
TypeBounds.upper(bound)
}
val bound = if ts.isEmpty then defn.AnyType else ts.reduceLeft(AndType.apply)
TypeBounds.upper(bound)
else NoType
}

var tparams = classTParams
Expand Down
1 change: 1 addition & 0 deletions tests/pos-java-interop-separate/i10225/A_1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class A_1<T> {}
3 changes: 3 additions & 0 deletions tests/pos-java-interop-separate/i10225/B_1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class B_1<S extends A_1> {
public B_1(S s) { }
}
4 changes: 4 additions & 0 deletions tests/pos-java-interop-separate/i10225/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
object Test {
val a = new A_1[String]
val b = new B_1(a)
}