chachako / sweekt Goto Github PK
View Code? Open in Web Editor NEW🍭 Some sugar to sweeten Kotlin development.
License: Apache License 2.0
🍭 Some sugar to sweeten Kotlin development.
License: Apache License 2.0
Suppress EqualsOrHashCode
when the class marked with @lazyinit
Class has 'equals()' defined but does not define 'hashCode()'
CodeFactor found an issue: Parentheses in (!predicate) are unnecessary and can be replaced with: !predicate
It's currently on:
library\src\commonMain\kotlin\com\meowool\sweekt\Exceptions.kt:39
This is meaningless, because the class will directly initialize the property when calling the constructor:
Meaningless b
:
class Foo(a: Boolean, @LazyInit val b: String = "String")
Foo(true) // in bytecode decompilation -> Foo(true, "String")
When these two compiler plugins are applied at the same time and the priority of sweekt is lower than compose, an error will occur. The simplest solution is that sweekt is applied earlier than compose
plugins {
id("com.meowool.sweekt") // must be before the compose or android app
// id("com.android.application")
id("org.jetbrains.compose")
}
https://youtrack.jetbrains.com/issue/KT-15555
var property: Any
get() = suspendGetter {
// suspended
}
set(value) = suspendSetter {
// suspended
}
Diagnosis:
@SuspendGetter
@SuspendSetter
Example:
val list = listOf(...)
// List<*> instance never be Array<*>
list.cast<Array<*>>()
list.castOrNull<Array<*>>()
Temporary solving https://youtrack.jetbrains.com/issue/KT-13108#focus=Comments-27-5474923.0-0
fun save(data: Union4<String, Int, Long, List<String>>): UnionType<Boolean, String> {
var result = Result(false)
when {
data is String -> { ... }
data is Int -> { ... }
data is Long -> { ... }
data is List<String> -> { ... }
data is Boolean -> { ... } // ERROR: Never this type
}
- return result // ERROR: Can only return 'Boolean' or 'String'
+ return result.value // OK: 'Boolean'
+ return result.value.toString() // OK: 'String'
}
fun main() {
save("Username") // OK: 'String'
save(50) // OK: 'Int'
save(1000000L) // OK: 'Long'
save(listOf("A", "B")) // OK: 'List<String>'
save(listOf("A", "B", 50)) // ERROR: Only 'List<String>' type are allowed
val any: Any = getAnyData()
save(any) // ERROR: 'Any' type not allowed
}
Diagnosis:
TypeChecker
CallChecker
`is` & `as` Checker
Suppress LeakingThis when the property in the abstract class is marked @LazyInit
您好!我是一名kotlin compiler的初学者,请问您可以告诉我怎么使用kotlin compiler去继承一个父类吗?比如:
open class A(){}
@随意的注解名
class B(){}
被注解的类可以变成:
class B:A(){}
十分感谢!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.