Skip to content

Commit a4f0d35

Browse files
Merge pull request #2538 from dotty-staging/fix-#2527
Fix #2527
2 parents 585ec67 + 5715f78 commit a4f0d35

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

compiler/src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,8 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
346346
if (prevInfo == null) tp.refinedInfo else prevInfo & tp.refinedInfo)
347347
formals = formals.updated(name, tp1.typeParamNamed(name))
348348
normalizeToRef(tp1)
349+
case tp @ RefinedType(tp1, _: TermName, _) =>
350+
normalizeToRef(tp1)
349351
case _: ErrorType =>
350352
defn.AnyType
351353
case AnnotatedType(tpe, _) =>

tests/pos/i2527.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object Foo {
2+
val f: Function0[Int]{ def apply(): Int } = () => 42
3+
}

tests/pos/i2527b.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Base
2+
3+
object Test {
4+
// OK
5+
val widen = {
6+
class Inner extends Base
7+
val f: () => Inner = { () => new Inner }
8+
f()
9+
}
10+
11+
// Crash
12+
val leak = {
13+
class Inner extends Base
14+
val f: (() => Inner){ def apply(): Inner } = { () => new Inner }
15+
f()
16+
}
17+
18+
}

0 commit comments

Comments
 (0)