From cc687b406d1f3a6f0f6d47a9d364c3eba46792e1 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 30 Aug 2014 12:46:57 +0200 Subject: Function and multi-array type methods get implicit contexts. Otherwise the context captured by Definitions applies. And that one leads to illegal types being constructed after erasure. We should think how we can better avoid the trap of captured contexts here. --- src/dotty/tools/dotc/core/Definitions.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/dotty/tools/dotc/core/Definitions.scala') diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala index c53e00152..cace6df74 100644 --- a/src/dotty/tools/dotc/core/Definitions.scala +++ b/src/dotty/tools/dotc/core/Definitions.scala @@ -361,9 +361,9 @@ class Definitions { sym.owner.linkedClass.typeRef object FunctionType { - def apply(args: List[Type], resultType: Type) = + def apply(args: List[Type], resultType: Type)(implicit ctx: Context) = FunctionClass(args.length).typeRef.appliedTo(args ::: resultType :: Nil) - def unapply(ft: Type)/*: Option[(List[Type], Type)]*/ = { + def unapply(ft: Type)(implicit ctx: Context)/*: Option[(List[Type], Type)]*/ = { // -language:keepUnions difference: unapply needs result type because inferred type // is Some[(List[Type], Type)] | None, which is not a legal unapply type. val tsym = ft.typeSymbol @@ -385,9 +385,9 @@ class Definitions { } object MultiArrayType { - def apply(elem: Type, ndims: Int): Type = + def apply(elem: Type, ndims: Int)(implicit ctx: Context): Type = if (ndims == 0) elem else ArrayType(apply(elem, ndims - 1)) - def unapply(tp: Type): Option[(Type, Int)] = tp match { + def unapply(tp: Type)(implicit ctx: Context): Option[(Type, Int)] = tp match { case ArrayType(elemtp) => elemtp match { case MultiArrayType(finalElemTp, n) => Some(finalElemTp, n + 1) -- cgit v1.2.3