Tree4Free / compilation-error-example

Strange compilation error. Example project for Issue: https://youtrack.jetbrains.com/issue/KT-38288

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compilation Error Example

The following code in the com.schuetz.Context class produces a compilation error:

package com.schuetz

object Context {
    fun <K : Any, V : Any> record(slice: Slice<K, V>, key: K, value: V): Unit = TODO("Not important for example")
    fun <K : Any, V : Any> get(slice: Slice<K, V>, key: K): V? = TODO("Not important for example")

    interface Slice<K: Any, V: Any>

    object Slices {
        object GENERAL: Slice<GENERAL.Key<*>, Any> {
            interface Key<T: Any> { // <- Error: Unresolved reference: Any
                fun get(): T {
                    return Context.get(GENERAL, this) as T
                }
                fun record(value: T) {
                    Context.record(GENERAL, this, value as Any)
                }
            }

            object Test: Key<String>
        }
    }
}

About

Strange compilation error. Example project for Issue: https://youtrack.jetbrains.com/issue/KT-38288

License:MIT License


Languages

Language:Kotlin 100.0%