Skip to content

Commit 8dfa9a5

Browse files
authored
Merge pull request #8040 from dotty-staging/fix-7990
Fix #7990: handle PolyType in constructor normalization
2 parents 9136d78 + 40edbd0 commit 8dfa9a5

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

Diff for: compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

+7-2
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,14 @@ class ClassfileParser(
271271
* and make constructor type polymorphic in the type parameters of the class
272272
*/
273273
def normalizeConstructorInfo() = {
274-
val mt @ MethodType(paramNames) = denot.info
275274
val rt = classRoot.typeRef appliedTo (classRoot.typeParams map (_.typeRef))
276-
denot.info = mt.derivedLambdaType(paramNames, mt.paramInfos, rt)
275+
276+
def resultType(tpe: Type): Type = tpe match {
277+
case mt @ MethodType(paramNames) => mt.derivedLambdaType(paramNames, mt.paramInfos, rt)
278+
case pt : PolyType => pt.derivedLambdaType(pt.paramNames, pt.paramInfos, resultType(pt.resType))
279+
}
280+
281+
denot.info = resultType(denot.info)
277282
addConstructorTypeParams(denot)
278283
}
279284

Diff for: tests/run/i7990/Exception_1.java

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public class Exception_1 {
2+
public <T> Exception_1(T actual, T matcher) {
3+
}
4+
5+
public Exception_1(String message) {
6+
}
7+
}

Diff for: tests/run/i7990/Test_2.scala

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@main def Test = Exception_1("error")

0 commit comments

Comments
 (0)