简体   繁体   中英

'MyMethod' in 'Dao_Impl' clashes with 'MyMethod + extends' in 'Dao'; both methods have same erasure, yet neither overrides the other

I wasnt getting any errors before. But today, i entered my project to edit and saw these errors.

First one is on this line;

public final class NoteDao_Impl implements NoteDao {

// The error code is : Class 'NoteDao_Impl' must either be declared abstract or implement abstract method 'getAllNotes(Continuation<? super List<? extends Notes>>)' in 'NoteDao'

I can fix it with Alt + Enter and then clicking 'implement methods' but just in case i want to write it.

The second one and third one is on these lines;

@Override
// Error : Method does not override method from its superclass
public Object getAllNotes(final Continuation<? super List<Notes>> continuation) {
// Error : 'getAllNotes(Continuation<? super List<Notes>>)' in 'com.ahmetkaan.kediy.data.NoteDao_Impl' clashes with 'getAllNotes(Continuation<? super List<? extends Notes>>)' in 'com.ahmetkaan.kediy.data.NoteDao'; both methods have same erasure, yet neither overrides the other

The NoteDao;

package com.ahmetkaan.kediy.data

import androidx.room.*

@Dao
interface NoteDao {

    @Query("SELECT * FROM notes ORDER BY id DESC")
    suspend fun getAllNotes() : List<Notes>

    @Query("SELECT * FROM notes WHERE id =:id")
    suspend fun getSpecificNote(id:Int) : Notes

    @Query("SELECT * FROM notes WHERE category = :id")
    suspend fun getCategoryNote(id:Int) : Notes

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertNotes(note:Notes)

    @Delete
    suspend fun deleteNote(note:Notes)

    @Query("DELETE FROM notes WHERE id =:id")
    suspend fun deleteSpecificNote(id:Int)

    @Update
    suspend fun updateNote(note:Notes)
}

The problem appears when i set getAllNotes() method as "getAllNotes(): List " So i guess thats why. But i dont understand why i get this error now. I do some research and i encounter some solutions like;

public class a<T extends Comparable> implements A<T>   

but probably i cant make it compatible with my project:,) Thanks in advance.

I met the same problem. I try this link to fix the problem. You can try changing List<Notes> to Array<Notes> . Hope it will help.

Also, if this error causes your app to crash at runtime, and you don't want to change the List to Array, maybe there is another approach. If you are using manual migration of the room database, try to change it to auto migration( Doc ). Although there still has this error in the build package, it won't affect your app performance. Your app can run without crashing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM