aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypeErasure.scala
Commit message (Collapse)AuthorAgeFilesLines
* Fix #1284: Make classTag depend directly on erasureMartin Odersky2016-07-251-0/+18
| | | | | | In the end, a classTag reflects the erased version of a type. The only condition for its generation should be that the erasure is stable under possible instantiations.
* Merge pull request #1343 from dotty-staging/change-hk-direct2odersky2016-07-151-1/+4
|\ | | | | Direct representation of higher-kinded types
| * Refactorings of GenericTypes and underlying/upperboundMartin Odersky2016-07-111-2/+0
| | | | | | | | | | | | | | 1. Make genericType a trait instead of a class. 2. Make TypeLambda a type proxy 3. Split underlying in TypeProxy into underlying and superType 4. Cleanups in many other places
| * Handle signatures over uninstantiated type variablesMartin Odersky2016-07-111-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Taking the signature over a type with uninstantiated type variables means that the signature can change later, once we instantiate the type variable. We handle this by recording uninstantiated positions of signatures and fixing them in PostTyper, when type variables are instantiated. - This allows to drop the kludge of "normalizing" in derivedRefinedType Dropping this initially revealed the problems with under-determined signatures. Now that these problems are fixed, we can drop for good.
| * Start new, direct HK schemeMartin Odersky2016-07-111-0/+2
| | | | | | | | | | - Re-introduce newHK option. Label some things that will be removed with OLD.
| * Allow general recursion in refined types.Martin Odersky2016-07-111-1/+1
| | | | | | | | | | Treat parent like refinedInfo. Introduce isBinding convenience method in TypeBounds.
* | Fix erasure of Java Array[T]Martin Odersky2016-07-141-1/+1
|/ | | | Should be erased to Object[], not Object.
* Don't force a symbol's denotation for isTerm/isTypeMartin Odersky2016-05-231-1/+1
| | | | | | | | Forcing it led to CyclicReferences involving RefChecks.OptLevelInfo when compiling dotc/*.scala against Tasty files. The problem was that when transforming OptLevelInfo the backend forced a transformInfo of RefChecks in TypeErasure which filtered RefCheck's scope to eliminate non-class type definitions. Without the tweak in this commit this tried to make all symbols current, and so came back to OptLevelInfo.
* Fix doc commentMartin Odersky2016-04-031-1/+1
|
* Make erased value type take a TypeRef instead of a ClassSymbolMartin Odersky2016-04-031-7/+7
| | | | To address #1198, we need to avoid putting symbols in ErasedValueTypes.
* Move Mode to coreMartin Odersky2016-04-011-1/+0
| | | | | Mode is used from a lot of low-level code, does not just reflect Typer info. So it makes more sense top to place it in the core package.
* Fix #1065 erasedLub for arrays of primitives.Dmitry Petrashko2016-02-081-2/+10
| | | | | | Unlike arrays of objects, that can be accessed as an array of a super type of this object, int[] cannot be accessed as an array of primitives.
* Fix erasure of raw arraysDmitry Petrashko2015-12-211-0/+1
|
* TypeErasure.isErasedType: scala.Array is invalid after Erasure.Dmitry Petrashko2015-12-201-1/+1
| | | | It should either be erased to j.l.Object or replaced by JavaArrayType.
* Compile scala.collection.Seq without double-binding errorGuillaume Martres2015-12-011-2/+4
| | | | | | | | | | | This commit fixes two issues which caused us to complete Seq too early and read it from the classpath instead of from the sources: - Evaluting RepeatedParamClass forced Seq, this is not necessary because the type of RepeatedParamClass is a LazyType - TypeErasure#sigName on a Scala type always forced Seq, even if the type is not a repeated param type. This fixes #980.
* Swap order of arguments in annotationsMartin Odersky2015-11-221-1/+1
| | | | | | | | | The fact that the annotation comes first is weird, because when I write an annotated type it's <type> @<annotation>. Also, annotated types are like RefinedTypes in that they derive from a parent type. And in RefinedTypes the parent comes first. So swapping the arguments improves consistency.
* Shorten ..Class.typeRef to ..TypeMartin Odersky2015-11-091-2/+2
| | | | | Since we now have two forms of (almost) everything in Definitions, might as well profit from it.
* Renamings in DefinitionsMartin Odersky2015-11-091-3/+3
| | | | | | TypeRef becomes Type, thus removing duplicates. Where ...Type was used in an extraction (e.g. ArrayType(...), FunctionType(...)), we now use ...Of.
* Avoid caching in sigNameMartin Odersky2015-10-221-8/+7
| | | | | | Use more complicated control flow with returns instead. sigName is likely performance critical, so some trickiness is justified.
* Hardening of sigName for ill-formed valueclassesMartin Odersky2015-10-221-33/+43
| | | | | | Need to survive even if a value class does not have an underlying type. Also: better diagnostics if sigName goes wrong.
* Better diagnostics for failed sigName calls.Martin Odersky2015-09-181-1/+5
| | | | | | It used to be "assertion error: NoType" whenever sigName git a projection of a missing member. Now we find out about what type was projected.
* Fix #791 erasedLub of two AnyVals is Object.Dmitry Petrashko2015-09-171-1/+5
|
* Error instead of crash when sigName comes up with a missing reference.Martin Odersky2015-07-061-0/+1
| | | | | | | | | | | | | | | | | | | A TypeRef can have be unresolved, either because it refers to something that's missing from the classpath or because of transitive self type references. Instead of crashing in sigName, we now report the error. Achieved by defining a new exception type, MissingType, which derives from TypeError. This catches t7933.scala, now integrated in the neg/selfreq.scala. The problem there was a reference to AbsSettings, which was not a member of StandardScalaSettings.this, but was a member of the required type of AbsSettings, which itself appeared in the required type of StandardScalaSettings. We will outlaw in the next commit such transitive required references. Also collapsed TypeError and FatalTypeError. It was a misnomer anyway. Fatal were those type errors that were caught and reported! Open: Where else we should check for unresolved NamedTypes.
* Get rid of semiEraseVCs boolean parametersMartin Odersky2015-06-261-8/+13
| | | | | | Replace by the pair of methods erasure/valueErasure. The boolean parameter is still kept, but only as a confuration parameter of the erasure objects.
* Fix erasure of Thistypes.Martin Odersky2015-06-261-5/+1
| | | | | | | | | | Thistypes erased to the underlying class. This is wrong. When seen as part of some other type, a ThisType has to erase to the erasure of the underlying type (i.e. the erasure if the selftype of the class). unittest-collections.scala failed with a MethodNotFound error because the erasure was computed incorrectly. On the other hand, a tree with a ThisType type, should keep the type, analogous to a tree with a TermRef type.
* TypeErasure#erasure: do not semi-erase types by defaultGuillaume Martres2015-06-241-3/+10
| | | | | | | This method can be called from other phases than Erasure, and in most cases we do not want the result to be semi-erased as this is an implementation details of value classes only useful to do type adaptation in the Erasure phase.
* Make ensureMethodic work after erasure.Martin Odersky2015-06-011-1/+1
| | | | | Previously it didn't, because it created an ExprType, which is illegal after erasure.
* Fix bug in typer erasure's transformInfoMartin Odersky2015-05-271-1/+1
| | | | ()Unit translates to ()BoxedUnit not BoxedUnit.
* Fixed foc of isUnboudnedGenericArrayMartin Odersky2015-05-081-3/+3
|
* Remove debug printlnMartin Odersky2015-05-061-1/+0
|
* Fix #540 - unbounded array test for wildcard array argumentsMartin Odersky2015-05-061-1/+3
| | | | | | Arrays with wildcard arguments such as Array[_ <: Foo] where Foo is a universal trait are now diagnosed as unbounded generic arrays and are erased to Object.
* Fix compatibility of Java with value classesGuillaume Martres2015-05-041-2/+5
| | | | | | | | | | This avoids getting a runtime error when calling a Java-defined method whose signature contains value classes. It happened because we erased the value classes in this signature even though it comes from a classfile. Amusingly, this problem also exists in scalac: <https://issues.scala-lang.org/browse/SI-9298>
* add an isCompanionMethod convenience methodGuillaume Martres2015-05-041-4/+4
|
* Fix companionClass not working after Erasure for value classesGuillaume Martres2015-05-011-1/+5
| | | | | | | | | | | For a module class V$, the synthesized companion class method looks like: val companion$class: V If V is a value class, after erasure it will look like: val companion$class: ErasedValueType(V, ...) This will break SymDenotation#companionClass which relies on the type of companion$class. The solution is to not semi-erase the type of companion$class.
* Erasure: properly erase value classesGuillaume Martres2015-05-011-8/+30
| | | | | | | | | | | | | | | | | | | | There are three ways to erase a value class: - In most case, it should be semi-erased to an ErasedValueType, which will be fully erased to its underlying type in ElimErasedValueType. This corresponds to semiEraseVCs = true in TypeErasure. - In a few cases, it should be erased like a normal class, so far this seems to be necessary for: * The return type of a constructor * The underlying type of a ThisType * TypeTree nodes inside New nodes * TypeApply nodes * Arrays In these cases, we set semiEraseVCs = false - When calling `sigName` it should be erased to its underlying type. This commit implements all these cases. Note that this breaks most tests because ElimErasedValueType has not been implemented yet, it is part of the next commit.
* Cache the instantiations of ErasedValueTypeGuillaume Martres2015-05-011-2/+25
| | | | | This reduces the number of objects created and speeds up subtyping tests Also make ErasedValueType extend ValueType
* TypeErasure: replace isSemi by semiEraseVCs and simplify the codeGuillaume Martres2015-05-011-30/+24
| | | | | | | | | | | | | | | - isSemi is replaced by semiEraseVCs with a different meaning (but is still unimplemented): * If true, value classes are semi-erased to ErasedValueType (they will be fully erased in ElimErasedValueType which is not yet present in this commit). * If false, they are erased like normal classes. - Fix the documentation of the TypeErasure class which was wrong. - Remove intermediate functions scalaErasureFn, scalaSigFn, javaSigFn and semiErasureFn. It's clearer to just use erasureFn directly instead. - Add an optional parameter semiEraseVCs to TypeErasure#erasure which will be used in Erasure#Typer when we need to disable semi-erasure.
* TypeErasure: simplify and fix bugsGuillaume Martres2015-05-011-15/+7
| | | | | | | | | | | | | | This commit tries to disentangle the TypeErasure class and the TypeErasure object thereby fixing #386. - Remove the `eraseInfo` method in the TypeErasure object, use `transformInfo` instead which takes care of using the correct instance of TypeErasure depending on the symbol to erase. - Remove the unused method `eraseResult` in the TypeErasure class. - In `transformInfo`, use the correct instance of the TypeErasure class when calling `eraseInfo`. - In the `eraseInfo` method of the TypeErasure class, do not call the `erasure` method of the TypeErasure object, instead use the `apply` method of the current instance of TypeErasure.
* Ensure spaces after `if` in Dotty source.Dmitry Petrashko2015-04-091-1/+1
|
* Changes to Tasty formatMartin Odersky2015-03-181-0/+418
Use fewer length fields in type encodings. - create new category of tags that take exactly one argument tree. - avoid using length where a tag fits in one of theopther categories.