Comments (5)
Annother test case
// decoder_1.scala
trait Decoder
object Decoder:
given foo: Int = ???
def bar(using d: M[Decoder]): Any = ???
type M[Y] = Y match
case Decoder => Int
// test_2.scala
// should fail, does when compiling at the same time as decoder_2.scala
def test: Unit = bar
from scala3.
This is a minimization from tests/pos/i15183
when compiling the two files at the same time.
from scala3.
Bar[Decoder]
has type
(using d: DecoderToInt[Decoder]): Any
Decoder
appears in that type, so it is in the implicit scope.
I think the issue has rather to do with match types. Sometimes they are resolved sometimes not, and the implicit scope is different for the two versions.
from scala3.
I can confirm, that's excactly what happens. decoder
and test
are run together, M[Decoder]
is simplified to Int
, so Decoder
does not reduce to the implicit scope. But if we compile test_2
separately, we still see an M[Decoder]
.
from scala3.
A related minimisation, where inference rather than implicit search, is impacted by whether or not the match type is reduced.
type MyMap[X] <: Any = X match
case Double => Int
def myMap[T]: MyMap[T] = ???
def derived(d: MyMap[Double]): Any = ???
val der = derived(myMap)
-- [E007] Type Mismatch Error: tests/pos/i15183b.scala:10:18 -----------------------------------------------------------
10 |val der = derived(myMap)
| ^^^^^
| Found: MyMap[T]
| Required: Int
|
| where: T is a type variable
|
|
| Note: a match type could not be fully reduced:
|
| trying to reduce MyMap[T]
| failed since selector T
| does not match case Double => Int
| and cannot be shown to be disjoint from it either.
|
| longer explanation available when compiling with `-explain`
But the same code is accepted when moving der
into a separate file and compiling with a classpath dependency.
from scala3.
Related Issues (20)
- Regression in `disneystreaming/smithy-translate` for inferred wildcard Java types
- Exports generate broken code depending on location (scope) of said code HOT 5
- Regression in 3.3.3 and 3.4.0 HOT 6
- Scala3 `-language` compiler option issues HOT 1
- Add support for type projections in presentation compiler
- Default given value doesn't work inside given definition
- scaladoc: does not include all inline concrete methods
- Crash when using Expr.summon with SeqMap HOT 2
- Beta-reduction of function type with by-name argument
- Parameterless extension method without parentheses is not called unless explicitly qualified by this HOT 3
- Implement Scala CLI as the `scala` runner command
- Macro extending selectable: very strange select behavior when accessing member value HOT 4
- write pipeline TASTy files asynchronously
- @tailrec and nested definitions
- Symbol.docString not available in tests HOT 2
- Regression in 3.4.1: spurious error when using transparent inline def unapply
- support escaping space in string literals using `\s` HOT 9
- Quote pattern not matching on *: when elements are tuples
- Inconsistency in type inference from function parameters HOT 1
- Missing punctuation in ScalaDoc
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scala3.