Skip to content

Commit f34ba39

Browse files
committed
Erase constant type
1 parent edeb3e1 commit f34ba39

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/compiler/scala/tools/nsc/transform/Constructors.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ abstract class Constructors extends Statics with Transform with TypingTransforme
607607

608608
private def triage() = {
609609
// Constant typed vals are not memoized.
610-
def memoizeValue(sym: Symbol) = !sym.info.resultType.isInstanceOf[FoldableConstantType]
610+
def memoizeValue(sym: Symbol) = enteringErasure(!sym.info.resultType.isInstanceOf[FoldableConstantType])
611611

612612
// The early initialized field definitions of the class (these are the class members)
613613
val presupers = treeInfo.preSuperFields(stats)

src/reflect/scala/reflect/internal/transform/Erasure.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ trait Erasure {
135135
case FoldableConstantType(ct) =>
136136
// erase classOf[List[_]] to classOf[List]. special case for classOf[Unit], avoid erasing to classOf[BoxedUnit].
137137
if (ct.tag == ClazzTag && ct.typeValue.typeSymbol != UnitClass) ConstantType(Constant(apply(ct.typeValue)))
138-
else tp
138+
else ct.tpe
139139
case st: ThisType if st.sym.isPackageClass =>
140140
tp
141141
case st: SubType =>

test/files/run/patmat-seq.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ package <empty> {
264264
()
265265
};
266266
def t(): Object = {
267-
case <synthetic> val x1: Int(2) = 2;
267+
case <synthetic> val x1: Int = 2;
268268
case16(){
269269
<synthetic> val o18: scala.collection.SeqOps = A.unapplySeq(x1);
270270
if (scala.collection.SeqFactory.UnapplySeqWrapper.isEmpty$extension(o18).unary_!())

0 commit comments

Comments
 (0)