| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
And remove the not used Printer#echo
|
|
|
|
|
|
| |
The issue fixed here was introduced by 71027f15. The added `csyms.isEmpty` condition on `case nil =>` is always true, which is clearely a bug.
t1500c still fails with covariant (or contravariant) type parameters on `::`, but this seams to be a more complicated issue involving the typer.
|
|
|
|
|
|
| |
Roll `sm` and `i` into one interpolator (also called `i`)
Evolve `d` to `em` interpolator (for error messages)
New interpolator `ex` with more explanations, replaces disambiguation.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Allows us to drop also the involved knownHK method. Lots of other
cleanups.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The problem is that some existential types read from Java (and Scala
as well? not sure) appear as naked typerefs. They consequently get
expanded via eta expansion to type lambdas. This commit compensates for
this by collapsing an eta expansion if this can make a subtype tests succeed
or a union or intersection be legal.
Also, take hk types into account for liftToClasses
Needs to special-treat TypeLambda and HKApply since otherwise
we risk creating malformed And-types.
|
|
|
|
|
|
|
|
|
|
|
|
| |
- Simplify RefinedType
- Drop recursive definition of RefinedThis - this is now
taken over by RecType.
- Drop RefinedThis.
- Simplify typeParams
The logic avoiding forcing is no longer needed.
- Remove unused code and out of date comments.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- compileMixed failed because there was a cycle between immutable.Seq (compiled) and
parallel.ParSeq (loaded from classfile). Inspection of the completion log (turn completions
Printer on) and the stack trace showed that there's nothing we can do here. The old hk scheme
did not go into the cycle because it did not force an unrelated type. I believe with enough
tweaking we would also hva egotten a cycle in the old hk scheme.
The test is "fixed" by adding parallel.ParSeq to the files to compile.
- Disable named parameter tests
Those tests do not work yet with the revised hk scheme.
Before trying to fix this, we should first decide what parts of
named parameters should be kept.
|
|
|
|
|
|
|
|
| |
In the new hk scheme, a type parameter can be represented by a
refinement without a corresponding symbol. Therefore, we need
to disentangle the info inherent in a type parameter from the
contents of a type symbol. We achieve this by creating a common
super trait "MemerInfo" of Symbol and RefinedType.
|
| |
|
|
|
|
| |
This reduces the number of implicit scopes we cache.
|
|
|
|
|
|
| |
Many intermediate `OfTypeImplicits` are created during a call to
`implicitScope`, but they won't all be used so there is no need to
compute `OfTypeImplicits#refs` unless it's actually used.
|
|
|
|
|
| |
This did not work before because we incorrectly looked for their value
in the prefix of the type instead of the type itself.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The issue is subtle: the `tp` in scope in `def ofTypeImplicits` is the
`tp` passed to the top-level `implicitScope` method, not the `tp` passed
to the recursively called `iscope`, this means that before this commit,
all intermediate `OfTypeImplicit` scopes cached while computing an
implicit scope had their `tp` field incorrectly set, which means that we
could miss implicits in later implicit searches.
Note that the `implicit_cache.scala` test worked before this commit
because of the restrictions on caching that exist since
b8b0f381ef2cbcb7bad66fd3e7a9ae929baa45f6, it is included anyway because
our caching strategy might change in the future.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
To make tests pass, this required a looser specification of
`assumedCanEquals`, so that an abstract type T can be compared to
arbitrary values, as long as its upper bound can be compared. E.g.
T == null
T == "abc"
|
| |
|
|
|
|
|
| |
Needed a fix in string interpolation for suriviving inserted
types that contain `$` characters.
|
| |
|
|
|
|
|
|
| |
This is done by checking each instance of an eqAny implicit
so that it does not contain non-bottom instances of equality
types as instances.
|
|
|
|
|
|
|
|
|
|
| |
Also, check that pattern matching against idents/selects/literals makes
sense.
The hooks perform an implicit search for an instance of `Eq[L, R]`, where
`L`, `R` are the argument types. So far this always succeeeds because Eq.eqAny
matches all such types. A separate commit will check the returned
search term for validity.
|
|
|
|
|
|
|
|
|
| |
Compare selected contravariant arguments as if they were covariant.
Which ones is explained in the doc comment for method `isAsSpecificValueType`
in Applications.scala.
This has the same motivation than what @paulp proposed around 2012. The solution is a bit
different from the one proposed then because it only affects top-level parameters.
|
|
|
|
|
|
| |
Caches were set when information was not complete yet. Problem was
exhibited by missing some `eqName` implicits when adding safe equality
for Name.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit fixes a very sneaky bug, the following code:
```
lazy val shadowing =
typed(untpd.Ident(ref.name) withPos pos.toSynthetic, funProto)
(nestedContext.addMode(Mode.ImplicitShadowing).setExploreTyperState)
```
is parsed by scalac as:
```
lazy val shadowing =
typed(untpd.Ident(ref.name) withPos pos.toSynthetic, funProto);
(nestedContext.addMode(Mode.ImplicitShadowing).setExploreTyperState);
```
So we don't actually use the nested context in `typed`, instead we end
up implicitly using `ctx`!
|
|
|
|
|
|
|
|
| |
An `C.this` term with erroneous class `C` will get a
`NoPrefix` type. A subsequent implicit search on this
crashed. This is fixed now.
Fixes #324.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When `wildApprox` encounters a PolyParam it approximates it by its
bounds in the current constraint set, but this is incorrect if
`TypevarsMissContext` is set, we might get the bounds of another use of
this `PolyType`. This is exactly what happened in i1044.scala where the
implicit view `refArrayOps` needs to be used twice with two different
type parameters.
The fix is to approximate a PolyParam by its original bounds in its
PolyType if `TypevarsMissContext` is set.
This fix was inspired by the approach of #1054.
|
|\
| |
| | |
Fix numeric implicit args
|
| |
| |
| |
| |
| | |
Dotty delivers an ambiguity error. The comment in the test argues why
this is OK.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Compiling scala.math.BigDecimal and scala.math.BigInteger shows a problem.
The conversion `int2bigInt` is not applicable to a Byte because `Byte -> Int`
requires another implicit conversion.
We fix that by using a new method relaxed_<:< for implicit compatibility checks,
which always admits numeric widenings.
This leads to another problem. Now the conversions
implicit def byteToInt(x: Byte): Int
implicit def byteToShort(x: Byte): Short
are ambiguous when we try to convert from Byte to Int.
We fix that by adding a "tie-break" to implicit search
where if several methods match a numeric value result type
and all have numeric value types as result types, we
pick the numerically largest type that matches.
|
|/
|
|
|
|
|
|
| |
These were disabled before, which means that having evidence
of S <:< T did not introduce a usable implicit conversion from
S to T. We do do it like scalac: just disable Predef.$conforms.
This makes TraversableOnce compile. Fixes #914.
|
|
|
|
| |
... making use of method in `ctx`.
|
|
|
|
|
|
|
| |
Add @sharable annotation for classes and vals that are presumed
to be safely sharable between threads.
Also: Document CtxLazy.
|
|
|
|
| |
Nothing will be committed here, so setExplore... is the right method to pick.
|
|
|
|
| |
Previously, we could die with a <notype> when an implicit argument was not found.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously `viewExists(X, Y)` failed if there were ambiguous
implicit conversions from X to Y. This is too fragile, as
demonstrated by test case run/array-addition.scala. Here,
the `genericArrayOps` implicit was not inserted because its
result type `Array[?T]` was deemed to be incompatible with
`? { +: : ? }`. It was incompatible because there were multiple
implicits that added :+ to arrays of various element types.
But once `genericArrayOps` gets applied, the type parameter
`?T` of the array result is fixed, and the ambuity goes away.
The scenario shows that we should not test for ambiguous implicits
in viewExists. Such a test is fragile because it depends on the
progress of type inference when the test is made. It's preferable
to just test for any implicit conversion to exist and to check
for ambiguities later, when the implicit conversion is actually
applied. This has also the potential of speeding up implicit search
in situations where `viewExists` is called often (e.g. when coupled
with overloading resolution).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Move addMode and friends to two decorators, one for Context, the other
for FreshContext. Implement behavior accordingly.
This avoids creating two contexts in situations like:
c.fresh.setxploreTyperState.addMode(...)
Mow we can write
c.fresh.addMode(...).setExploreTyperState
Because addMode returns a fresh context when applied to a fresh context.
Note that we specifically do not want virtual dispatch of addMode, that's
why it was moved to a decorator.
Also: removed mention of ".fresh: when just forllowed by an addMode, because
that one is redundant.
|
|
|
|
|
| |
Factor out isValueSubClass into separate method. Will probably come in handly
elsewhere, and makes the code easier to understand.
|
|
|
|
|
|
|
|
|
| |
Shadowing tests could go into an infinite recursion when
the found sahdwoing member itself needs an implicit that
is resolved and then shadowed again by the same member.
A test case is neg/arrayclone-new.scala. This caused
a SO before, now gives two errors.
|
|
|
|
|
| |
I scanned the main sources with IntellIJ's spell checker and
corrected what showed up.
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
This way, tpd#applyOverloaded can safely be used after typer. This issue
was encoutered while working on value classes, step 3 of SIP-15 contains
the following peephole optimization:
new C(e) == new C(f) => e == f
Which requires us to do overloading resolution.
|
|
|
|
|
|
|
| |
The implicit def was shadowed by a following import. Scalac did not detect the problem probably because
the import and the def were in the same scope. But selecting the member explicitly would have caused an error
because the import came after the definition. So arguably this was in error, but scalac did not detect
it correctly.
|
|
|
|
|
|
|
|
|
| |
This fixes #347.
When Config.cacheImplicitScopes == false or an implicit scope is
requested for a type for which it cannot be cached, this change
causes the same computation to be applied as if the scope were
looked up in the implicit scope cache and not found.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- Instead of rebasing, use the DeBrujn level of a RefiendThis.
- Make sure lower type is a singleton by skolemizing it if necessary.
- Do the correct rebinding of the upper type's RefinedThis.
Remarks:
- The new scheme discovered quite a lot of errors which are mostly fixded in
other commits of this branch. i0268 (GADT matching) still does not work, moved to pending.
- Some optimizations are currently missing:
(1) fast path refined subtyping
(2) faster operations for substituting refined thistypes which
explot the fact that RefinedThis is relatively rare.
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is necessary to reject code like
val x: Boolean = null
Without the restriction, this code would typecheck and expand to
val x: Boolean = Predef.Boolean2boolean(null)
since `null` counts as a value of type `java.kang.Boolean`.
|