Skip to content

Commit 76ce7c7

Browse files
committed
Fix problems with lazy vals and separate compilation
Somehow this error manifested itself in a quite weird way during erasure. So it was hard to track down
1 parent a6640ab commit 76ce7c7

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/dotty/tools/dotc/transform/LazyVals.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ class LazyVals extends MiniPhaseTransform with SymTransformer {
2727

2828

2929
def transformSym(d: SymDenotation)(implicit ctx: Context): SymDenotation = {
30-
if(d is(Flags.Lazy, butNot = Flags.ModuleVal)) {
30+
if(d is(Flags.Lazy, butNot = Flags.ModuleVal | Flags.Method)) {
31+
// Method flag is set on lazy vals coming from Unpickler. They are already methods and shouldn't be transformed twice
3132
d.copySymDenotation(
3233
initFlags = d.flags | Flags.Method,
3334
info = ExprType(d.info))

tests/pos/lazyValsSepComp.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package dotty.tools
2+
package io
3+
4+
import java.io.{ InputStream }
5+
import java.util.jar.JarEntry
6+
import dotty.tools.dotc.core.Definitions
7+
import language.postfixOps
8+
import dotty.tools.dotc.core.Contexts._
9+
10+
11+
/** A test to trigger issue with separate compilation between Dotty and Scalac and lazy vals */
12+
object Foo {
13+
val definitions: Definitions = null
14+
def defn = definitions
15+
def go = defn.FunctionClass(0)
16+
}

0 commit comments

Comments
 (0)